/*	Copyright 2013 RangerUFO
 *
 *	This file is part of Libevent-helper.
 *
 *	Libevent-helper is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU Lesser General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	Libevent-helper is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU Lesser General Public License for more details.
 *
 *	You should have received a copy of the GNU Lesser General Public License
 *	along with Libevent-helper.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __libevent_helper_acceptor_h__
#define __libevent_helper_acceptor_h__

#ifdef __cplusplus
extern "C" {
#endif  // __cplusplus

#include <event2/event.h>

struct evacceptor;
struct evsession;

typedef void (*evacceptor_cb)(struct evacceptor*, struct evsession*, void*);
typedef void (*evacceptor_error_cb)(struct evacceptor*, void*);

struct evacceptor* evacceptor_new_bind(struct event_base* base, const char* ip, int port, int backlog);
void evacceptor_free(struct evacceptor* ac);
struct event_base* evacceptor_get_base(struct evacceptor* ac);

void evacceptor_setcb(
		struct evacceptor* ac,
		evacceptor_cb accept_cb,
		evacceptor_error_cb error_cb,
		void* args);

int evacceptor_enable(struct evacceptor* ac);
int evacceptor_disable(struct evacceptor* ac);

#ifdef __cplusplus
}
#endif  // __cplusplus

#endif  // __libevent_helper_acceptor_h__
